using System;
using System.Collections.Generic;
using System.Xml;
using System.Collections.ObjectModel;

namespace planning
{
	public class Horaire : Ressource
	{
		// ----- ATTRIBUTS -----
		private DateTime debut;
		private DateTime fin;

		// ----- CONSTRUCTEURS -----
		public Horaire()
		{
			// Start of user code for default constructor
			// End of user code for default constructor
		}

		// ----- ACCESSEURS -----
		public DateTime Debut
		{
			get { return debut; }
			set { debut = value; ObjectChanged("debut"); }
		}

		public DateTime Fin
		{
			get { return fin; }
			set { fin = value; ObjectChanged("fin"); }
		}


		static Dictionary<string, Horaire> references = new Dictionary<string, Horaire>();

		public static new Horaire fromXml(XmlNode node)
		{
			if(node.SelectSingleNode("@ref") != null)
				return references[node.SelectSingleNode("@ref").Value];

			Horaire horaire = new Horaire();

			if(node.SelectSingleNode("@id") != null) {
				references.Add(node.SelectSingleNode("@id").Value, horaire);
			}

			horaire.Debut = Convert.ToDateTime(node.SelectSingleNode("@debut").Value);
			horaire.Fin = Convert.ToDateTime(node.SelectSingleNode("@fin").Value);
			

			return horaire;

		}

	}

}
